package modele;

import java.io.Serializable;



public class Case implements Comparable<Case>, Serializable
{
	private static final long serialVersionUID = 3208207000888983462L;
	private int x;
	private int y;
	private Case precedente;
	//private Integer distanceAvant;
	private Distance distance;
	

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void plus(Direction direction)
	{
		if(direction == Direction.BAS)
			y = y-1;
		else if(direction == Direction.HAUT)
			y = y+1;
		else if(direction == Direction.GAUCHE)
			x = x-1;
		else
			x = x+1;
	}
	
	public Case(int x, int y)
	{
		this.x = x;
		this.y = y;
	}
	
	public Case(Position pos)
	{
		this.x = pos.getC();
		this.y = pos.getL();
	}
	
	public Case(Case c)
	{
		this.x = c.x;
		this.y = c.y;
	}

	public Case getPrecedente() {
		return precedente;
	}

	public void setPrecedente(Case precedente) {
		this.precedente = precedente;
	}
	
	public Distance getDistance() {
		return distance;
	}

	public void setDistance(Distance distance) {
		this.distance = distance;
	}
	
	public void afficherPartiellement()
	{
		System.out.println("("+x+","+y+")");
	}
	
	public void afficher()
	{
		System.out.println("("+x+","+y+") ,"+distance.getAvant()+","+distance.getApres());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + x;
		result = prime * result + y;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Case other = (Case) obj;
		if (x != other.x)
			return false;
		if (y != other.y)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Case(" + x + ", " + y + ")";
	}


	@Override
	public int compareTo(Case o) {
		return distance.compareTo(o.distance);
	}


	
	
	
	
}